package com.nbsaas.boot.shop.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.LongEntity;
import com.nbsaas.boot.rest.filter.Operator;
import lombok.Data;
import org.hibernate.annotations.Comment;

import javax.persistence.*;
import java.util.Date;

@SearchBean(
        items = {
         @SearchItem(label = "广告位key", name = "key",key = "shopBannerPosition.kry",operator = Operator.eq)
        }
)
@Data
@FormAnnotation(title = "商家广告图")
@Entity
@Table(name = "bs_shop_banner")
public class ShopBanner extends LongEntity {

    @SearchItem(label = "商家", name = "shop", key = "shop.id", operator = Operator.eq, classType = Long.class,show = false)
    @Comment("商家id")
    @JoinColumn(name = "shop_id",foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
    @FieldConvert
    @FieldName
    @ManyToOne(fetch = FetchType.LAZY)
    private Shop shop;


    @SearchItem(label = "广告位", name = "shopBannerPosition",key = "shopBannerPosition.id",classType = Long.class,operator = Operator.eq)
    @FormField(title = "广告位", grid = true, col = 22,type = InputType.select,option = "shopBannerPosition")
    @FieldName
    @FieldConvert
    @ManyToOne(fetch = FetchType.LAZY)
    private ShopBannerPosition shopBannerPosition;

    @SearchItem(label = "名称", name = "name")
    @FormField(title = "名称", grid = true, col = 22)
    @Column(length = 20)
    private String name;

    @FormField(title = "广告图",col = 22,type = InputType.image)
    @Column(length = 300)
    private String logo;

    @FormField(title = "banner地址", grid = true, col = 22)
    @Column(length = 20)
    private String url;

    @FormField(title = "添加入", grid = true, col = 22,ignore = true)
    @FieldConvert
    @ManyToOne(fetch = FetchType.LAZY)
    private ShopStaff staff;


    @FormField(title = "排序号", grid = true, col = 22,type = InputType.el_input_number,sort = true)
    @Comment("排序号")
    private Integer sortNum;


    @FormField(title = "添加时间", grid = true, width = "10000", ignore = true)
    @Comment("添加时间")
    private Date addDate;

    @Comment("最新修改时间")
    private Date lastDate;

}
